package oop.ex1.filters;

import java.io.File;

/**
 * a filter that checkes if the file is smaller than a given value 
 * @author danalmog
 * @author danielshalev
 */
public class Smaller extends SizeDependent {

	/**
	 * construct a new filter and send the relevant values to it's super 
	 * @param size the size to compare to
	 * @param hasNot determines if we should use as a NOT filter
	 */
	public Smaller(String size, boolean hasNot) {
		super(size,hasNot);
	}
	
	/**
	 * checks if the given files is smaller then desired value
	 * @param pathname the file to compare it's size
	 * @return true if the file has passed the filter false otherwise
	 */
	public boolean accept(File pathname){
		if(((double)pathname.length()/SIZE_CONVERTER<getSize() && !hasNot) || ((double)pathname.length()/SIZE_CONVERTER>=getSize() && hasNot))
			return true;
		return false;
	}
}
